    var canvasBuffer = document.createElement('canvas');
    var canvas = document.getElementById('maincanvas');
    var wrapper = document.getElementById('wrapper');
    var contextBuffer = canvasBuffer.getContext('2d');
    var context = canvas.getContext('2d');
    var youTubeReady =false;
    var time = new Date().getTime() / 1000;
    var delta = 0;
    var startTime = new Date().getTime() / 1000;
    var elements = new Array();
    var boxes = new Array();
    var score = 0;
    var music = new Audio("portfolioIntro.wav"); 
    var timeElement;
    var scoreElement;
    var muted = true;
    var videoPlayer;

    // canvasBuffer.setAttribute('tabindex','0');
    canvas.setAttribute('tabindex','0');
  	canvas.focus(); 
    canvasBuffer.height = window.innerHeight;
    canvasBuffer.width = window.innerWidth;
    canvas.height = window.innerHeight;
    canvas.width = window.innerWidth;

    canvasBuffer.height = window.innerHeight;
    canvasBuffer.width = window.innerWidth;
    canvas.height = window.innerHeight;
    canvas.width = window.innerWidth;
    contextBuffer.mozImageSmoothingEnabled = false;
    contextBuffer.webkitImageSmoothingEnabled = false;
    contextBuffer.imageSmoothingEnabled = false;
    context.mozImageSmoothingEnabled = false;
    context.webkitImageSmoothingEnabled = false;
    context.imageSmoothingEnabled = false;
    function on_resize()
    {
        canvasBuffer.height = window.innerHeight;
        canvasBuffer.width = window.innerWidth;
        canvas.height = window.innerHeight;
        canvas.width = window.innerWidth;
        contextBuffer.mozImageSmoothingEnabled = false;
        contextBuffer.webkitImageSmoothingEnabled = false;
        contextBuffer.imageSmoothingEnabled = false;
        context.mozImageSmoothingEnabled = false;
        context.webkitImageSmoothingEnabled = false;
        context.imageSmoothingEnabled = false;
        // canvasBuffer.height = 320;
        // canvasBuffer.width = 480;
        console.log("resize");
        checkBounds();
        player.jumpSpeed = canvasBuffer.height *3.4;
       // player.y = canvasBuffer.height - player.height -200;
        console.log(player.y);

        game.floor.top = canvasBuffer.height -12;
        game.floor.right = 100000;
        game.floor.bottom = canvasBuffer.height; 
        camera.resize();

    }


    function on_load()
    {
      // videoPlayer = new YT.Player("video1");
      contextBuffer.mozImageSmoothingEnabled = false;
      contextBuffer.webkitImageSmoothingEnabled = false;
      contextBuffer.imageSmoothingEnabled = false;
      context.mozImageSmoothingEnabled = false;
      context.webkitImageSmoothingEnabled = false;
      context.imageSmoothingEnabled = false;
      console.log("load");
      checkBounds();
        // music.play();
    }
    window.requestAnimFrame = (function(callback) 
    {
     return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
      function(callback) {
      console.log("callback fallback");
      window.setTimeout(callback, 1000 / 60);
     }
    // };
    // })();
    })();

function onYouTubePlayerAPIReady(){videoPlayer = new YT.Player(); youTubeReady = true;};


(function() {
    var lastTime = 0;
    var vendors = ['webkit', 'moz'];
    for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
        window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
        window.cancelAnimationFrame =
          window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
    }

    if (!window.requestAnimationFrame)
        window.requestAnimationFrame = function(callback, element) {
            var currTime = new Date().getTime();
            var timeToCall = Math.max(0, 16 - (currTime - lastTime));
            var id = window.setTimeout(function() { callback(currTime + timeToCall); },
              timeToCall);
            lastTime = currTime + timeToCall;
            return id;
        };

    if (!window.cancelAnimationFrame)
        window.cancelAnimationFrame = function(id) {
            clearTimeout(id);
        };
}());




    function hitLink( link, callback, target)
    { 
         document.onclick=  function(e){
         e.preventDefault();
        
        
      }
      if(target == "_blank")
      {
          window.open(link, "_blank");
      }
      else{
        window.setTimeout(function(){
                

                var xmlhttp;
                if (window.XMLHttpRequest)
                  {// code for IE7+, Firefox, Chrome, Opera, Safari
                  xmlhttp=new XMLHttpRequest();
                  }
                else
                  {// code for IE6, IE5
                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                  }
                xmlhttp.onreadystatechange=function()
                  {
                  if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {
                    document.getElementById("content").innerHTML=xmlhttp.responseText;
                    if(callback)
                    callback();
                    }
                      window.setTimeout(function(){checkBounds();
                       document.onclick= function(e){return true;};}, 550);

                  }
                xmlhttp.open("GET", link,true);
                xmlhttp.send();




        }, 100);
        canvasBuffer.focus();
        
        
    }
    }

    function triggerPowerup(element){
      if(!hasClass(element, "active-powerup"))
      element.className= "active-powerup";
    }
    function hasClass(element, cls) {
    return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
    }
   


  


//google showed me these... need to use them later to optimize (batching dom changes)
function removeToInsertLater(element) {
  var parentNode = element.parentNode;
  var nextSibling = element.nextSibling;
  parentNode.removeChild(element);
  return function() {
    if (nextSibling) {
      parentNode.insertBefore(element, nextSibling);
    } else {
      parentNode.appendChild(element);
    }
  };
}

function doesNothing()
{
  console.log("did nothing");
}



function updateAllAnchors(element, anchorClass) {
  var insertFunction = removeToInsertLater(element);
  var anchors = element.getElementsByTagName('a');
  for (var i = 0, length = anchors.length; i < length; i ++) {
    anchors[i].className = anchorClass;
  }
  insertFunction();
}